#include "systemversionview.h"

SystemVersionView::SystemVersionView(QWidget *parent)
    : QWidget{parent}
{
    setUI();
}

void SystemVersionView::setUI()
{
    QWidget *baseWidget = new QWidget(this);
    baseWidget->setFixedSize(384,558);

    vLayout = new QVBoxLayout();
    vLayout->setContentsMargins(0,0,0,0);
    vLayout->setSpacing(0);
    setLayout(vLayout);

    label = new QLabel("系统版本:");
    label->setObjectName("title");
    label->setAlignment(Qt::AlignLeft);


    centerWidget =new QWidget();
    QList <QString> list,vlist;
    list<<"DMI软件版本"<<"DMI配置版本"<<"激活司机室"<<"VATO数据库版本"<<"VATP数据库版本";
    vlist<<"0.4.15"<<"1.0.0"<<"A"<<"10.24"<<"2.12";
        for (int i = 0; i < 5; i++) {
        versionTextWidget[i] = new VersionTextWidget(list[i],vlist[i],centerWidget);
        versionTextWidget[i]->setGeometry(0,25*i,384,25);
    }

    bottomWidget = new QWidget();
    closebtn = new QPushButton("退出",bottomWidget);
    closebtn->setGeometry(0,62,108,62);
    closebtn->setObjectName("baseBtn");


    vLayout->addWidget(label,62);
    vLayout->addWidget(centerWidget,372);
    vLayout->addWidget(bottomWidget,124);
}

VersionTextWidget::VersionTextWidget(QString leftText, QString rightText, QWidget *parent): QWidget{parent}
{
    hLayout = new QHBoxLayout();
    hLayout->setSpacing(0);
    hLayout->setContentsMargins(0,0,0,0);
    setLayout(hLayout);

    for (int i = 0; i < 3; i++) {
        QString s = "";
        int w = 0;
        switch (i) {
        case 0:
            s = leftText;
            w = 160;
            break;
        case 1:
            s = ":";
            w = 14;
            break;
        case 2:
            s = rightText;
            w = 210;
            break;
        default:
            break;
        }
        label[i] = new QLabel(s);
        if(i == 0){
            label[i]->setStyleSheet("color:white;font-size:14px;padding-left:40px");
        }else{
            label[i]->setStyleSheet("color:white;font-size:14px;");
        }

        label[i]->setAlignment(Qt::AlignLeft);

        hLayout->addWidget( label[i],w);
    }
}




